package com.fiona.start.base;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fiona.common.extension.ExtensionLoader;
import com.fiona.start.IStart;
import com.fiona.start.some.StartParam;
import com.fiona.start.some.StartSome;

/**
 * 加载所需的资源
 */
public class StartLoad {
	private static Logger log = LoggerFactory.getLogger(StartLoad.class);

	/**
	 * 加载所需的资源
	 * 
	 * @param packName  要扫描的包
	 * @param startList 要加载的责任链
	 * @throws Exception 异常
	 */
	public static void load(Class<?> packName) throws Exception {

		StartParam startParam = new StartParam();
		startParam.setClazz(packName);
		List<StartSome> startList = ExtensionLoader.getExtensionLoader(StartSome.class).getExtensionList();
		for (int i = 0; i < startList.size(); i++) {
			log.info("start num:{} starter, is {}", i, startList.get(i).getClass().getSimpleName());
			startList.get(i).load(startParam);
			log.info("{} started.", startList.get(i).getClass().getSimpleName());
		}
	}
}
